package com.zhixin.zhixinmall.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.zhixin.zhixinmall.entity.result.ResultMap;

import jakarta.servlet.http.HttpServletRequest;

/**
 * @author cyc
 * @date 2023/10/08 15:44:55
 */
@RestControllerAdvice
@ResponseBody
public class ZhixinMallExceptionHandler {
    private Logger logger = LoggerFactory.getLogger(ZhixinMallExceptionHandler.class);

    @ExceptionHandler(value = Exception.class)
    public ResultMap exceptionHandler(HttpServletRequest request, Exception e) {
        logger.error("异常信息：{}", e.getMessage());
        return ResultMap.error("服务端异常，请联系管理员" + "<br/>" + e.getMessage());
    }

}
